<template>
	<div class="user_setting">
		<head-title title="设置--交易设置"></head-title>
		<el-card>
			<el-form :model="passwordForm" :rules="passwordFormRules" ref="passwordForm" label-width="240px">
				<div class="password-view">
					<p class="title">交易设置</p>
					<el-form-item label="供应商默认佣金系数:" prop="factory_commission"><el-input style="width: 300px" placeholder="请输入供应商默认佣金系数" v-model="passwordForm.factory_commission"><template slot="append">%</template></el-input></el-form-item>
					<el-form-item label="经销商默认佣金系数:" prop="commission_coefficient">
						<el-input placeholder="请输入经销商默认佣金系数" v-model="passwordForm.commission_coefficient" style="width: 300px"><template slot="append">%</template></el-input>
					</el-form-item>
					<el-form-item label="供应商默认冻结时间（已收货后）:" prop="thaw_day">
						<el-input placeholder="请输入供应商默认冻结时间" v-model="passwordForm.thaw_day" style="width: 300px"><template slot="append">天</template></el-input>
					</el-form-item>
					<el-form-item>
						<el-button type="primary" @click="submit('passwordForm')">保存</el-button>
					</el-form-item>
				</div>
			</el-form>
		</el-card>
	</div>
</template>

<script>
export default {
	components: {},
	data() {
		return {
			passwordForm: {
				factory_commission: '',
				commission_coefficient: '',
				thaw_day: '',
				config_id: ''
			},
			passwordFormRules: {
				factory_commission: [{ required: true, message: '请输入供应商默认佣金系数' }],
				commission_coefficient: [{ required: true, message: '请输入经销商默认佣金系数' }],
				thaw_day: [{ required: true, message: '请输入供应商默认冻结时间' }],
			}
		};
	},
	methods: {
		init(){
			this.$http(this.$ApiList.ConfigInfo).then(res => {
				for(let i in this.passwordForm){
					this.passwordForm[i] = res.datas[i]
				}
			})
		},
		submit(formName) {
			this.$refs[formName].validate(valid => {
				if (valid) {
					this.$http(this.$ApiList.ConfigInfo, this.UpdateConfig).then(res => {
						if (res.code == 200) {
							this.$layer.msg('修改成功');
						}
					});
				} else {
					this.$layer.msg('请填写完整信息后提交');
				}
			});
		}
	},
	created() {
		this.init()
	}
};
</script>
<style>
.user_setting .password-view {
	width: 400px;
}
</style>
